class Platform {
	/**
	 * 运行环境
	 */
	static platform = '';
	/**
	 * 是否 app
	 */
	static isApp = false;
	/**
	 * 是否 浏览器
	 */
	static isH5 = false;
	/**
	 * 是否 微信小程序
	 */
	static isWxMp = false;
	/**
	 * 是否 字节跳动小程序
	 */
	static isTtMp = false;
	/**
	 * 是否 小程序
	 */
	static isMp = false;
	/**
	 * 是否 android app
	 */
	static isAndroid = false;
	/**
	 * 是否 ios app
	 */
	static isIos = false;
	/**
	 * 是否 ios 浏览器
	 */
	static isIosH5 = false;
	/**
	 * 是否为开发环境
	 */
	static isDevEnv = process.env.NODE_ENV === 'development';
	/**
	 * 是否为开发生产
	 */
	static isProdEnv = process.env.NODE_ENV === 'production';
	/**
	 * 是否是微信
	 */
	static isWx = false;
	/**
	 * 是否在企业微信
	 */
	static isWxWork = false;
	/**
	 * 是否在企业微信手机端
	 */
	static isWxWorkMobile = false;
	/**
	 * 是否在企业微信PC端
	 */
	static isWxWorkPc = false;
	/**
	 * 海通 webview
	 */
	static isHaitongWebview = false;
	/**
	 * H5 并且不是微信
	 * */
	static isH5NotWx = false;
	/**
	 * H5 PC
	 */
	static isH5Pc = false;
	/**
	 * H5 Mobile
	 */
	static isH5Mobile = false;
	/**
	 * h5 iphone
	 */
	static isH5Iphone = false;
	/**
	 * 是否是 h5 钉钉
	 */
	static isH5Dingtalk = false;
}

//#ifdef APP-PLUS
Platform.isApp = true;
Platform.platform = 'app';
//#endif

//#ifdef APP-PLUS-NVUE
//#endif

//#ifdef H5
Platform.isH5 = true;
Platform.platform = 'h5';
//#endif

//#ifdef MP-WEIXIN
Platform.isWxMp = true;
Platform.platform = 'wxmp';
//#endif

//#ifdef MP-ALIPAY
//#endif

//#ifdef MP-BAIDU
//#endif

//#ifdef MP-TOUTIAO
Platform.isTtMp = true;
Platform.platform = 'ttmp';
//#endif

//#ifdef MP-QQ
//#endif

//#ifdef MP-360
//#endif

//#ifdef MP
Platform.isMp = true;
//#endif

//#ifdef quickapp-webview
//#endif

//#ifdef quickapp-webview-union
//#endif

//#ifdef quickapp-webview-huawei
//#endif

Platform.isAndroid = Platform.isApp && uni.getSystemInfoSync().platform === 'android';

Platform.isIos = Platform.isApp && uni.getSystemInfoSync().platform === 'ios';

// ios 浏览器
if (Platform.isH5) {
	//#ifdef H5
	const userAgent = window.navigator.userAgent || '';
	Platform.isIosH5 = !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
	//#endif
}

// 微信
if (Platform.isH5) {
	const reg = /micromessenger/i;
	const test = reg.test(navigator.userAgent);
	Platform.isWx = test;
}
// 企业微信 
if (Platform.isWx) {
	const reg = /wxwork/i;
	const test = reg.test(navigator.userAgent);
	Platform.isWxWork = test;
}
// 企业微信手机端
if (Platform.isWxWork) {
	const reg = /mobile/i;
	const test = reg.test(navigator.userAgent);
	Platform.isWxWorkMobile = test;
}

// 企业微信PC端
if (Platform.isWxWork) {
	const reg = /windows/i;
	const test = reg.test(navigator.userAgent);
	Platform.isWxWorkPc = test;
}

// 海通 webview
if (Platform.isH5) {
	const reg = /kkPlus/i;
	const test = reg.test(navigator.userAgent);
	Platform.isHaitongWebview = test;
}

// H5 并且不是微信
if (Platform.isH5) {
	const reg = /micromessenger/i;
	const test = reg.test(navigator.userAgent);
	Platform.isH5NotWx = !test;
}
// H5 Mobile
if (Platform.isH5) {
	const test = !!(navigator.userAgent.match(/Mobi/i) || navigator.userAgent.match(/Android/i) || navigator.userAgent
		.match(/iPhone/i));
	Platform.isH5Mobile = test;
}
// H5 PC
if (Platform.isH5) {
	Platform.isH5Pc = !Platform.isH5Mobile;
}
// h5 iphone
if (Platform.isH5) {
	Platform.isH5Iphone = Platform.isH5Mobile && /iphone/gi.test(navigator.userAgent);;
}
// 是否是 h5 钉钉
if (Platform.isH5) {
	Platform.isH5Dingtalk =  /dingtalk/gi.test(navigator.userAgent);
}

export {
	Platform,
};